package com.ohos.connect.devicecloud.app.modular.user.api;

import cn.hutool.core.util.ObjectUtil;
import com.ohos.connect.devicecloud.app.api.AppUserApi;
import com.ohos.connect.devicecloud.app.modular.user.model.entity.AppUser;
import com.ohos.connect.devicecloud.app.modular.user.service.AppUserService;
import com.ohos.connect.devicecloud.common.exception.CommonException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("appUserApi")
public class AppUserApiImpl implements AppUserApi {

    @Resource
    private AppUserService appUserService;

    @Override
    public String getUserAccountById(String userId) {
        if(ObjectUtil.isEmpty(userId)){
            throw new CommonException("用户id不能为空");
        }

         AppUser appUser = appUserService.getById(userId);
         if(ObjectUtil.isNull(appUser)) {
             throw new CommonException("账号不存在");
         }
        return appUser.getAccount();
    }
}
